#include<cpp.h>
using namespace std;

typedef vector<int> ve;

bool check(const int& a, const int& b)
{
    return abs(a - b) == 1;//相邻差值为1
}
int MLS(vector<int>& arr) {
    int n = arr.size();
    sort(arr.begin(), arr.end());
    int ret = 1;
    ve dp(n,1);
    for (int i = 1; i < n; i++)
    {
        if (check(arr[i], arr[i - 1]))
            dp[i] = dp[i - 1] + 1, ret = max(ret, dp[i]);
        else if (arr[i] == arr[i - 1])dp[i] = dp[i - 1];

    }

    return ret;
}

int main()
{
    vector<int> arr{ 1,1,1,1 };
    int ret=MLS(arr);
    cout << ret << endl; 
    return 0;
}